package com.wms.controller;

import com.wms.bean.ResultBean;
import com.wms.core.R;
import com.wms.mapper.WareAndLocMapper;
import com.wms.service.WareAndLocService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@Api(tags = "skh-根据仓库id查询所包含的库区和货位名称")
public class WareAndLocController {
    @Autowired
    WareAndLocMapper wareAndLocMapper;
    
    @Autowired
    WareAndLocService wareAndLocService;

    @GetMapping("wareAndLoc/queryAllStores")
    @ApiOperation("查询所有仓库")
    public ResultBean queryAllStores() {
        List<Map> stores = wareAndLocMapper.queryAllStoreId();
        if (stores != null && !stores.isEmpty()) {
            return R.success("查询成功", stores);
        }
        return R.fail("查询失败");
    }

    @GetMapping("wareAndLoc/queryWareAndLocByStoreId")
    @ApiOperation("根据仓库id查询所包含的库区和货位名称")
    public ResultBean queryWareAndLocByStoreId(int storeId) {
       List list = wareAndLocService.queryWareAndLocByStoreId(storeId);
        if (list!=null){
            return R.success("查询成功",list);
        }
        return R.fail("查询失败");
    }

    @GetMapping("wareAndLoc/queryUsers")
    @ApiOperation("查询所有用户")
    public ResultBean queryUsers() {
        List<Map> users = wareAndLocMapper.queryAllUsers();
        if (users != null && !users.isEmpty()) {
            return R.success("查询成功", users);
        }
        return R.fail("查询失败");
    }
}
